var currentTab = null;
$(function () {
   $('#back').click(function () {
       var schoolId = $(this).attr('nodeId');
       window.top.frames['targetFrame'].location.href = baseUrl+'frontend/school_examine/yearGrade/'+schoolId;
       $('.modal-title',window.parent.document).html('历年成绩');
   });

   $('.clickable').click(function () {
       var tag = $(this).parent().attr('sTag');
       var nodeId = $(this).attr('nodeId');
       if(tag == 'tchUse'){
           xhTop.showModal({
               title:'熟练度详情',
               content:'<iframe src="'+baseUrl+'school_examine/tchUseDetail/'+nodeId+'"  style="width: 100%;;border-style: none;padding: 0px;height:350px"  scrolling="yes"  ></iframe>',
           })
       }else if (tag == 'runExamine') {
           xhTop.showModal({
               title:'运营详情',
               content:'<iframe src="'+baseUrl+'school_examine/RunDetail/'+nodeId+'"  style="width: 100%;;border-style: none;padding: 0px;height:350px"  scrolling="yes"  ></iframe>',
           })
       }else if(tag == 'activity'){
           window.top.xhTop.createNewTab('学校活动', baseUrl+'article/activityList?schoolId='+schId, true);
           // xhTop.showModal({
           //     title:'学校活动',
           //     content:'<iframe src="'+baseUrl+'school_examine/actDetail/'+nodeId+'"  style="width: 100%;;border-style: none;padding: 0px;height:350px"  scrolling="yes"  ></iframe>',
           // })
       } else if (tag == 'tchShare') {
           window.top.xhTop.createNewTab(schName+'--教师交流分享', baseUrl+'school_share/schoolShare?schoolId='+schId, true);
       } else if (tag == 'exCase') {
           window.top.xhTop.createNewTab('运营案例', baseUrl+'article/msgList?type=7&schoolId='+schId, true);
       } else if (tag == 'runCase') {
           window.top.xhTop.createNewTab('运营案例分享', baseUrl+'school_share/caseShareList?schoolId='+schId, true);
       }
   });


   $('.fix').click(function () { //修改
       var id     = $(this).attr('nodeId');
       var action = $(this).text();
       var gradeDom = $('#grade_'+id);
       if(action == '修改'){
           var grade  = gradeDom.text();
           gradeDom.empty();
           gradeDom.append('<input name="grade" value="'+grade+'" class="form-control">');
           $(this).text('提交');
       }else if (action == '提交'){
           var grade = gradeDom.find('[name=grade]').val();
          xhExtra.askChangeStatus('school_examine/changeGrade',{id:id,grade:grade},null,'确认要提交嘛？',function (res) {
              window.top.xhTop.showSuccess(res.msg);
              gradeDom.empty().text(grade);
              $('.fix').text('修改');
              // window.top.frames['targetFrame'].location.reload();
          })
       }
   });

   $('.lock').click(function () { //锁定
       var id  = $(this).attr('nodeId');
       xhExtra.askChangeStatus('school_examine/lockNode',{id:id},null,'确认要锁定嘛？',function (res) {
           window.top.xhTop.showSuccess(res.msg);
           window.top.frames['targetFrame'].location.reload();
       })
   });

   $('.unlock').click(function () { //解锁
       var id  = $(this).attr('nodeId');
       xhExtra.askChangeStatus('school_examine/unLockNode',{id:id},null,'确认要解锁嘛？',function (res) {
           window.top.xhTop.showSuccess(res.msg);
           window.top.frames['targetFrame'].location.reload();
       })
   });

   //一键锁定
   $('#lockAll').click(function () {
       var id = $('table').attr('nodeId');
       xhExtra.askChangeStatus('school_examine/lockAll',{id:id},null,'确认要锁定全部嘛？锁定后只有管理可以修改',function (res) {
           window.top.xhTop.showSuccess(res.msg);
           window.top.frames['targetFrame'].location.reload();
       })
   });


});
